package com.ds.infra.rpc.core.transport.client.handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;

/**
 * 客户端连接生命周期管理
 *
 * @author WeiShaoying
 */
@Slf4j
public class RpcClientHandlerV1 extends ChannelInboundHandlerAdapter {
    @Override
    public void channelActive(ChannelHandlerContext ctx) {
        log.debug("Connection established: {}", ctx.channel().remoteAddress());
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) {
        log.warn("Connection lost: {}", ctx.channel().remoteAddress());
        // 触发重连逻辑
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        log.error("Client handler error", cause);
        ctx.close();
    }
}
